{-# LANGUAGE OverloadedStrings #-}
module Pages.AddSubmission(submissionForm) where

import Control.Applicative
import State.Database

import Text.Blaze.Html5.Formlets
import Text.Blaze.Html5 (p, div, span, toHtml)
import qualified Text.Blaze.Html5.Attributes as A

import Prelude hiding (div, span)

import Pages.Formlets(inputProgram, labelled)

-- | A form for the input of submission info
submissionForm :: (Applicative m, Monad m) => (ProblemId -> m Bool) -> Html5Form m (ProblemId, Program)
submissionForm checkProblemId = do
    let
        pidForm = labelled "Problem Id:" (ProblemId <$> inputInteger Nothing)
                    `checkM` (ensureM checkProblemId "The problem specified does not exist") 
        programForm = labelled "Program:" (inputProgram Nothing)
    liftA2 (,) pidForm programForm 
